using UnityEngine;
using System.Collections;

public class PickupSkullOnTrigger : MonoBehaviour {
	
	public AudioSource audioSource;
	public Texture icon;
	
	public AudioClip playOnTrigger;
	public bool onTrigger = false;
	
	private bool triggered = false;
	
	void OnTriggerEnter(Collider other) {
		if (other.tag == "Player" && !triggered && onTrigger) {
			triggered = true;
			Pickup_Skull();
		}
	}
	
	void  OnMouseUpAsButton() { 
		Pickup_Skull();
	}
	
	void Pickup_Skull() {
		audioSource.PlayOneShot(playOnTrigger);
		
		Skull1 newSkull = new Skull1();

		newSkull.icon = icon;
		Game.inventory.items[newSkull.index] =newSkull;
		
		Object.Destroy(gameObject);
	}
}
